#include <cstdio>
#include <cstring>

const int M = 310;
int mp[105][M], v1, v2, flag[M], match[M];
int dfs(int u ) {
    int i, tmp;
    for ( i = 1; i <= v2; i++ )
        if ( !flag[i] && mp[u][i] ) {
             flag[i] = 1;
             tmp = match[i];
             match[i] = u;
             if ( tmp == 0 || dfs(tmp) )
			 	return 1;
             match[i] = tmp;
        }
    return 0;
}

int bipartite() {
    int i, cnt = 0;
    memset(match, 0, sizeof(match) );
    for ( i = 1; i <= v1; i++ ) {
        memset(flag, 0, sizeof(flag ) );
        cnt += dfs(i);
    }
    return cnt == v1;
}

int main () {
    int tt, i, j, m, y;
    scanf("%d", &tt);
    while ( tt-- ) {
          scanf("%d %d", &v1, &v2);
          memset(mp, 0, sizeof(mp) );
          for ( i = 1; i <= v1; i++ ) {
              scanf("%d", &m);
              for ( j = 1; j <= m; j++ ) {
                  scanf("%d", &y);
                  mp[i][y] = 1;
                  }
              }
          if ( v1 > v2 ) {
               printf("NO\n");
               continue;
               }
          if ( bipartite() ) printf("YES\n");
          else printf("NO\n");
          }
    return 0;
    }